package com.example.hello;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class sp_adapter extends ArrayAdapter{


    public sp_adapter(@NonNull Context context, int resource, @NonNull ArrayList<HashMap<String,String>> list) {
        super(context, resource, list);
    }

    public View getView(int position, View convertView, ViewGroup parent){
        View itemView = convertView;
        if(itemView==null){
            itemView = LayoutInflater.from(getContext()).inflate(R.layout.sp_list,parent,false);
        }

        Map<String,String> sp_map = (Map<String,String>) getItem(position);
        TextView title = (TextView) itemView.findViewById(R.id.sportTitle);
        TextView detail = (TextView) itemView.findViewById(R.id.sportDetail);

        title.setText(sp_map.get("sportTitle"));
        detail.setText( sp_map.get("sportDetail"));

        return itemView;
    }
}
